package com.jy.api.signUpReq.stock;

import com.jy.api.domain.StockChangeReason;
import com.jy.api.enums.StockInSourceEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * Created by lihu on 2018/1/31.
 */

@Data
@NoArgsConstructor
@AllArgsConstructor
public class InvntSignupReq {

    @NotNull(message = "参数错误")
    private String id;

    @NotNull(message = "参数错误")
    private String storeId;

    @NotNull(message = "参数有误")
    private String operatorId;
    @NotNull(message = "参数有误")
    private String operatorName;

    /**
     * 入库总金额
     */
    private int totalAmount;

    /**
     * 单据图片地址
     */
    private String bill;

    /**
     * 备注
     */
    private String notes;


    /**
     * 个
     */
    private int single;

    /**
     * 件
     */
    private int whole;

    /**
     * 出入库原因
     */
    @NotNull(message = "请选择出入库来源")
    private StockChangeReason stockSource;

    /**
     * 出入库地址
     */
    private StockInSourceEnum source;


    @Size(min = 1, message = "请选择入库商品")
    private List<Inventore> inventores;

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class Inventore {


        @NotNull(message = "参数有误")
        private String productId;

        private String productName;

        @Min(value = 0, message = "入库数量必须大于等于0")
        private int whole;

        @NotNull(message = "请填写商品规格")
        private int stockQuantityRatio;

        private int stockPrice = 0;

        public int getTotal() {
            return  whole * stockQuantityRatio;
        }
    }
}
